<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <common-head></common-head>
  </div>

  <!-- <script id="tpl" type="text/html">
    <div>
      <h2>我是commonHead组件</h2>
    </div>
  </script> -->
  <template id="tpl">
    <div>
      <h2>你好commonHead组件</h2>
    </div>
  </template>
  <script src="./vue.js"></script>
  <script>

    const CommonHead = {
      template:'#tpl',
      data(){
        return {
          msg: '你好组件'
        }
      },
      methods: {
        changeMsg(){
          this.msg = '数据改变了'
        }
      },
      watch: {
        msg(newVal){
          console.log('值改变了',newVal);
        }
      },
      computed: {
        reverseMsg(){
          return this.msg.split('').reverse().join('');
        }
      },
      mounted(){
        console.log(this);
      }
    }
    Vue.component('CommonHead', CommonHead)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>